import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { Permission } from './permission.entity';

@Entity()
export class Widget {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ length: 50, comment: '按钮权限code' })
  code: string;

  @Column({ length: 50, comment: '按钮权限名称' })
  name: string;

  @Column({ comment: '对应的路由id' })
  routeId: number;

  @ManyToOne(() => Permission, (permission) => permission.widgets)
  @JoinColumn({ name: 'routeId' })
  permission: Permission;
}
